package org.loon.game.sample.llk.Map.xml;

import java.io.FileOutputStream;
import java.io.IOException;

public class LXmlWriter {
	
	FileOutputStream os = null;
	XmlSerializer xmlSerializer = (XmlSerializer) new KXmlSerializer();
	
	public LXmlWriter(String filePath) throws IllegalArgumentException, IllegalStateException, IOException{
		os =  new FileOutputStream(filePath);
		xmlSerializer.setOutput(os, "UTF-8");
		xmlSerializer.startDocument("UTF-8", true);
	}
	
	public void writeSingleTag(String name,String value) throws IllegalArgumentException, IllegalStateException, IOException{
		xmlSerializer.startTag("", name);
		xmlSerializer.text(value);
		xmlSerializer.endTag("", name);
	}
	
	public XmlSerializer getXMLWriter(){
		return xmlSerializer;
	}
	
	public void end() throws IOException{
		xmlSerializer.endDocument();
		os.flush();
		os.close();
	}
	
}
